package com.troila.cloud.simplify.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.troila.cloud.simplify.model.SQuestion;
import com.troila.cloud.simplify.repository.SQuestionRepository;

@Service
@Transactional
public class SQuestionService {
	
	@Autowired
	private SQuestionRepository sQuestionRepository;
	
	public void delQuestion(int id) {
		sQuestionRepository.delete(id);
	}
	
	public void save(List<SQuestion> sQuestions) {
		for (int i = 0; i < sQuestions.size(); i++) {
			sQuestionRepository.save(sQuestions.get(i));
		}
	}
	
	public List<SQuestion> findByATitleId(int sTitleId){
		return sQuestionRepository.findBySTitleIdOrderByANumAsc(sTitleId);
	}

}